#include <stdio.h>


#define N 10

void routine(double * a, int size ) {
    double b[N];
    double red = 0;
    int i;
    int np = 7;
    #pragma acc kernels copy(a[size],b,np,red) copyin(size,i)
    {
            #pragma acc loop private(i) reduction(+ : red)
            for (i = 0; i < size; i++) {
                    a[i] = np + i;
                    b[i] = a[i];
                    red += 2.0f;
            }
    }
    for (i = 0; i < size; i++) {
        printf("b[%d] = %g \n", i, b[i]);
    }
    printf("** Red %g \n", red);

};

int main () {
    int i, size;
    double * a;

    a = malloc(N * sizeof(double));
    size = N;
    routine (a, size);
    #pragma acc data copy(a[size])
    {
        int i;
        for (i = 0; i < size; i++)
            routine(a, size);
    }

    for (i = 0; i < size; i++) {
        printf("a[%d] = %g \n", i, a[i]);
    }

}
